
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BusinessObject;
using DataAccessLayer;

namespace BusinessLogic
{
    /// <summary>
    /// Define CategoryUtil class. This class user for BussinessLayer.

    /// </summary>
    public class CategoryUtil
    {
        /// <summary>
        /// Define function Insert for Category Object.
        /// </summary>
        /// <param name="t">object data need Insert.</param>
        /// <returns>
        ///    True: if insert successfull.
        ///    False: if insert error.
        ///</returns>
        public static int Insert(Category t)
        {
            BizObject.PurgeCacheItems("Category");

            return CategoryDao.Insert(t);
        }
        /// <summary>
        /// Define function Update for Category Object.
        /// </summary>
        /// <param name="t">project data need updated.</param>
        /// <returns>
        ///    True: if update successful.
        ///    False: if update Error.
        ///</returns>
        public static bool Update(Category t)
        {
            BizObject.PurgeCacheItems("Category");

            return CategoryDao.Update(t);
        }
        /// <summary>
        /// Get All Category object from table Category.
        /// </summary>
        /// <returns>List Category object.</returns>
        public static List<CategoryResult> GetAll()
        {
            List<CategoryResult> obj = null;
            string key = "Category_GetAll";
            if (BizObject.Cache[key] != null)
            {
                obj = (List<CategoryResult>)BizObject.Cache[key];
            }
            else
            {
                obj = CategoryDao.GetAll();
                BizObject.CacheData(key, obj);
            }
            return obj;
        }
        /// <summary>
        /// Search Category object in table Category.
        /// </summary>
        /// <param name="t">Condition for Search.</param>

        /// <returns>List CategoryResult objects.</returns>

        public static List<CategoryResult> SearchCategorySomeCondition(Category t)
        {
            return CategoryDao.SearchCategorySomeCondition(t);
        }
        /// <summary>
        /// Get a Category data object by primary key. 
        /// </summary>
        /// <param name="categoryId" >This is primary key.</param>
        /// <returns>A Category object.</returns>

        public static Category Get(string categoryId)
        {
            Category obj = null;
            string key = "Category_Get_" + string.Format("{0}", categoryId);
            if (BizObject.Cache[key] != null)
            {
                obj = (Category)BizObject.Cache[key];
            }
            else
            {
                obj = CategoryDao.Get(categoryId);
                BizObject.CacheData(key, obj);
            }
            return obj;
        }

        /// <summary>
        /// This function to Delete Category object by primary key.
        /// </summary>
        /// <param name="categoryId" >This is primary key.</param>
        /// <returns>If succesful return True else  return False.</returns>

        public static bool Delete(string categoryId)
        {
            BizObject.PurgeCacheItems("Category");

            return CategoryDao.Delete(categoryId);
        }
        public static bool Publish(Category obj)
        {
            return CategoryDao.Publish(obj);
        }
        public static List<CategoryResult> GetAllCategoryToControl()
        {
            return CategoryDao.GetAllCategoryToControl();
        }
    }
}